package com.erp.framework.types;

import java.sql.Timestamp;

import com.erp.framework.SimpleConstants;
import com.erp.framework.util.CommonUtil;

public class CustomTimestamp extends Timestamp implements SimpleConstants {
    
    /**
     * @param time
     */
    public CustomTimestamp(long time) {
        super(time);
    }

    /**
     * @param date
     */
    public CustomTimestamp(java.util.Date date) {
        super(date.getTime());
    }

    /**
     * @param date
     */
    public CustomTimestamp(java.sql.Date date) {
        super(date.getTime());
    }

    /**
     * @param date
     */
    public CustomTimestamp(java.sql.Timestamp date) {
        super(date.getTime());
    }

    /**
     * @deprecated
     * @param year
     * @param month
     * @param date
     * @param hour
     * @param minute
     * @param second
     * @param nano
     */
    public CustomTimestamp(int year, int month, int date, int hour, int minute, int second, int nano) {
        super(year, month, date, hour, minute, second, nano);
    }

    public static CustomTimestamp customize(java.util.Date date){
        if(date == null){
            return null;
        } else {
            return new CustomTimestamp(date);
        }
    }
    
    public static CustomTimestamp customize(java.sql.Date date){
        if(date == null){
            return null;
        } else {
            return new CustomTimestamp(date);
        }
    }
    
    public static CustomTimestamp customize(java.sql.Timestamp date){
        if(date == null){
            return null;
        } else {
            return new CustomTimestamp(date);
        }
    }
    
    public String toString() {
        return CommonUtil.dateToString(this, OUTPUT_DATETIME_FORMAT);
    }
}
